import java.util.*;
import java.io.*;
public class 二维差分模板牛客 {
    /**
     *     https://www.nowcoder.com/practice/50e1a93989df42efb0b1dec386fb4ccc
     *     和地毯一样, 主要是模板直接记住, 边界处理
     *     这一题最特别的就是如果数组里面本身不是都为0的数组, 要如何去解决
     *     通过每个数组的元素, 每一个都进行差分来完成这个操作
     */
    //https://www.luogu.com.cn/problem/P3397
    //二维差分的模板题
    public static long[][] arr = new long[1005][1005];//测试数据不会超过这个数组
    public static int n;
    public static int m;

    //快读快写, 不然会超时的
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();
    public static void main(String[] args) throws IOException{
        n = in.nextInt();
        m = in.nextInt();
        int q = in.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                //将每个数组的元素单个差分直接加入
                set(i,j,i,j,in.nextInt());
            }
        }
        while(q-- > 0){
            //四个坐标, 然后先一个个填入差分数组里面
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            int k = in.nextInt();
            set(a,b,c,d,k);
        }
        //一次搞定
        build();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                out.print(arr[i][j] + " ");
            }
            out.println();
        }
        out.close();
    }

    private static void build() {
        for (int i = 1; i <= n + 1; i++) {
            for (int j = 1; j <= m + 1; j++) {
                //二维前缀和的第一个加和
                arr[i][j] += arr[i][j - 1] + arr[i - 1][j] - arr[i - 1][j - 1];
            }
        }
    }
    //直接套模板即可
    private static void set(int a, int b, int c, int d, int k) {
        arr[a][b] += k;
        arr[a][d + 1] -= k;
        arr[c + 1][b] -= k;
        arr[c + 1][d + 1] += k;
    }
    public static class Read {
        StringTokenizer st = new StringTokenizer("");
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String next() throws IOException
        {
            while(!st.hasMoreTokens())
            {
                st = new StringTokenizer(bf.readLine());
            }
            return st.nextToken();
        }

        String nextLine() throws IOException
        {
            return bf.readLine();
        }

        int nextInt() throws IOException
        {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException
        {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException
        {
            return Double.parseDouble(next());
        }
    }
}
